package com.company;

import java.text.DecimalFormat;

// intcount 类用于i数字中  0~9数字统计，以数组方式retrun
public class intcount {
    public static int[] count (int i){ //定义count 函数，作用于0~9 数字统计
        int outArry[]= new int[10]; //定义对外return 数组，存放0~9数字统计
        int zer = 0, fir = 0, sec = 0, thi = 0, fou = 0, fiv = 0, six = 0, sev = 0, eig = 0, nin = 0;
        String si = Integer.toString(i);
        char tempArray[] = si.toCharArray();
        for (int j = 0; j < tempArray.length; j++){
            if (tempArray[j] == '0')
            {
                zer++;
            }
            else if (tempArray[j] == '1')
            {
                fir++;
            }
            else if (tempArray[j] == '2')
            {
                sec++;
            }
            else if (tempArray[j] == '3')
            {
                thi++;
            }
            else if (tempArray[j] == '4')
            {
                fou++;
            }
            else if (tempArray[j] == '5')
            {
                fiv++;
            }
            else if (tempArray[j] == '6')
            {
                six++;
            }
            else if (tempArray[j] == '7')
            {
                sev++;
            }
            else if (tempArray[j] == '8')
            {
                eig++;
            }
            else
            {
                nin++;
            }
        }

        outArry[0]=zer;
        outArry[1]=fir;
        outArry[2]=sec;
        outArry[3]=thi;
        outArry[4]=fou;
        outArry[5]=fiv;
        outArry[6]=six;
        outArry[7]=sev;
        outArry[8]=eig;
        outArry[9]=nin;
   // return  new int outArry[]{zer,fir,sec,thi,fou,fiv,sev,eig,nin};
    return outArry;

    }


}
